<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="${package.Mapper}.${cfg.moduleName}.${table.mapperName}">
    <#if enableCache>
        <!-- 开启二级缓存 -->
        <cache type="org.mybatis.caches.ehcache.LoggingEhcache"/>
    </#if>

    <select id="selectMySqlPage" resultType="${cfg.basePath}.domain.${cfg.moduleName}.${entity}">
        select t1.*, t2.nick_name as createUserName, t3.nick_name as updateUserName
        from ${table.name} t1
        left join easy_user t2 on t1.create_user_id = t2.id
        left join easy_user t3 on t1.update_user_id = t3.id
        <where>
            <if test="query.keyword != null and query.keyword != '' ">
                 and t1.id like concat('%', ${r"#{query.keyword}"}, '%')
            </if>
            <if test="query.beginTime != null and query.beginTime != '' ">
                <![CDATA[ and t1.create_time >= ${r"#{query.beginTime}"} ]]>
            </if>
            <if test="query.endTime != null and query.endTime != '' ">
                <![CDATA[ and t1.create_time <= ${r"#{query.endTime}"} ]]>
            </if>
        </where>
        order by t1.id desc
    </select>
</mapper>